<script type="text/javascript" src="/public/other/ckeditor/ckeditor.js"></script>
<script type="text/javascript">
    window.onload = function()
    {
        CKEDITOR.replace('ckeditor',{skin:'moono',width:'800',height:'400'});
    };
</script> 
<div class="wrapper">
    <h1>编辑文章：</h1>
    <ul>
            <li>分类：
                <select name="category" class="ipt_select">
                    <?php foreach($category as $cate):?>
                    <option value="<?php echo $cate['cid'];?>" <?php if($thread['cid'] == $cate['cid']):?>selected="selected"<?php endif;?>><?php echo $cate['cname'];?></option>
                    <?php endforeach;?>
                </select>
            </li>
            <li>标题：<input type="text" name="title" class="ipt_blank" value="<?php echo $thread['title'];?>" /></li>
            <li>作者：<input type="text" name="author" class="ipt_blank" value="<?php echo $thread['author'];?>" /></li>
            <li>链接：<input type="text" name="link" class="ipt_blank" value="<?php echo $thread['link'];?>" /></li>
            <li>时间：<input type="text" name="datetime" class="ipt_blank" value="<?php echo date("Y-m-d H:i:s",$thread['datetime']);?>" /></li>
            <li style="height:650px;">内容：<textarea name="content" id="ckeditor"><?php echo $thread['content'];?></textarea></li>
            <li><a href="javascript:void(0)" class="a_btn update_thread">保存</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:history.go(-1)" class="a_btn">返回</a><a class="red alter"></a></li>
    </ul>
</div>
<script type="text/javascript">
    $(".update_thread").click(function(){
       var tid = <?php echo $thread['tid'];?>;
       var cid = $("select[name=category]").val();
       var title = $("input[name=title]").val();
       var author = $("input[name=author]").val();
       var link = $("input[name=link]").val();
       var datetime = $("input[name=datetime]").val();
       var content = CKEDITOR.instances.ckeditor.getData();
       
       if(title == '' || title == null || title.length == 0) {
           _alert("请输入文章标题");
           $("input[name=title]").focus();
           return false;
       }
       
       if(content == '' || content == null || content.length == 0) {
           _alert("请输入文章内容");
           CKEDITOR.instances.ckeditor.focus();
           return false;
       }
       
       var url = "/index.php?c=admin&m=updateThread";
       var data = {tid:tid,cid:cid,title:title,author:author,link:link,content:content,datetime:datetime};
       var res = _ajax(url,data);
       _ajax_alert(res);
    });
</script>